#------------------------------------------------------------------------------
# That's just a makefile for documentation refresh: you only need this if you
# modify manual.txt or the source code of the handLaTeX driver.
#
# It needs:
#
# - GNU make (obviously - tested on GNU make 3.81)
# - asciidoc (tested on asciidoc 8.1.0)
# - some html to text dumper (links by default: change below).
# - help2man (tested on GNU help2man 1.36)
# - man (tested on man 1.6e and GNU groff 1.19.2)
# - python (tested on python 2.5.1)
# - find (tested on GNU find 4.3.6)
#
# Invoke as make VERSION='x.x.x' 
#------------------------------------------------------------------------------
export ASCIIDOC = asciidoc
export HTMLDUMP = links -dump -width 80 -html-numbered-links 1
export HELP2MAN = help2man --no-info
export PYTHON   = python

#------------------------------------------------------------------------------
ROOTDOC = $(shell cd .. ; pwd)

ifndef VERSION
all:
	$(error VERSION not defined: invoke as "gmake VERSION=x.x.x")
else
all: dumpversion
endif

all: ../README ../README.html ../handlatex.1

../README: ../README.html
	$(HTMLDUMP) $< | sed 's,file://$(ROOTDOC)/,,' > $@ 

../README.html: notes.txt ../handlatex.1 .version
	$(ASCIIDOC) --unsafe --conf-file=manual.conf \
		-a revision="$(VERSION)" \
		-a theme=hand -a stylesdir=`pwd` \
		-o $@ $<

../handlatex.1: ../handlatex
	$(HELP2MAN) $< > $@

.version:
	dumpversion

.SECONDARY: .version

.PHONY: clean dumpversion

dumpversion:
	@test "x`cat .version`" = x$(VERSION) || \
		echo $(VERSION) > .version

clean:
	-rm -f ../README
	-rm -f ../README.html
	-rm -f ../handlatex.1
	-find .. -name '*~' -exec rm -f \{\} ';'

#------------------------------------------------------------------------------
